package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

class zapt {
   Workbook a;
   ArrayList b;
   ArrayList c;
   ArrayList d;
   ArrayList e;
   ArrayList f;
   ArrayList g;
   int[] h;
   HashMap i;
   private String[] o;
   HashMap j;
   ArrayList k;
   private zaqg p;
   String l;
   String m;
   boolean n;

   zapt(Workbook var1) {
      this.a = var1;
      this.b = new ArrayList();
      this.f = new ArrayList();
      this.d = new ArrayList();
      this.e = new ArrayList();
      this.f = new ArrayList();
      this.g = new ArrayList();
      this.c = new ArrayList();
      this.i = new HashMap();
      this.o = new String[this.a.getWorksheets().getCount()];
      this.j = new HashMap();
      this.k = new ArrayList();
      this.p = new zaqg(this.a.getWorksheets());
      if (var1.getSaveOptions() instanceof OdsSaveOptions && ((OdsSaveOptions)var1.getSaveOptions()).isStrictSchema11()) {
         this.m = "1.1";
         this.l = "oooc:";
         this.n = false;
      } else {
         this.m = "1.2";
         this.l = "of:";
         this.n = true;
      }

   }

   public String a(Cell var1) {
      byte[] var2 = var1.v();
      if (var2 == null) {
         return var1.g().k();
      } else if (this.a.getWorksheets().x().a((byte)1, var2)) {
         byte var3 = 0;
         byte var4 = 0;
         int[] var5 = new int[]{var3};
         int[] var6 = new int[]{var4};
         this.a.getWorksheets().x().a(var2, var5, var6);
         int var8 = var5[0];
         int var9 = var6[0];
         Cell var7 = var1.d.get(var8, var9);
         return var7.D() != null ? this.p.a(-1, -1, var7.D().d(), var1.getRow(), var1.getColumn(), !var7.D().b()) : null;
      } else {
         return this.p.a(-1, var2, var1.getRow(), var1.getColumn(), false);
      }
   }

   void a() {
      for(int var1 = 0; var1 < this.o.length; ++var1) {
         this.a.getWorksheets().get(var1).b(this.o[var1]);
      }

      Set var4 = this.j.keySet();
      Iterator var2 = var4.iterator();

      while(var2.hasNext()) {
         int var3 = (Integer)var2.next();
         this.a.getWorksheets().getNames().get(var3).g((String)this.j.get(var3));
      }

   }

   void b() {
      Object[] var1 = zaqh.a(this.a);

      for(int var2 = 0; var2 < this.a.getWorksheets().getCount(); ++var2) {
         Worksheet var3 = this.a.getWorksheets().get(var2);
         this.o[var2] = var3.getName();
         zapu var4 = new zapu(this, var3);
         var4.a(this);
         com.aspose.cells.b.a.a.ze.a(this.g, (Object)var4);
      }

      this.c();
      this.a((ArrayList)var1[2]);
      this.b((ArrayList)var1[0]);
      this.a((zbvx)var1[1]);
   }

   private void c() {
      NameCollection var1 = this.a.getWorksheets().getNames();

      for(int var2 = 0; var2 < var1.getCount(); ++var2) {
         Name var3 = var1.get(var2);
         if (var3.getSheetIndex() != 0) {
            this.j.put(var2, var3.getText());
            var3.g(var3.getText() + "_" + var3.getSheetIndex());
         }
      }

   }

   private void a(int var1) {
      zaqb var2 = new zaqb();
      com.aspose.cells.b.a.a.ze.a(this.e, (Object)var2);
      var2.a = "N" + var1;
      var2.d = 1;
      zaqq var3 = new zaqq(4, (String)null);
      com.aspose.cells.b.a.a.ze.a(var2.f, (Object)var3);
      com.aspose.cells.b.a.a.ze.a(var3.b, (Object)(new String[]{"min-integer-digits", "1"}));
   }

   void a(ArrayList var1) {
      this.a(0);

      for(int var4 = 0; var4 < var1.size(); ++var4) {
         zaqp var5 = (zaqp)var1.get(var4);
         int var2 = var5.a;
         String var3 = var5.b;
         if (zaqh.e(var3) && var2 > 0) {
            var3 = zbqc.a(var2);
         }

         if (zaqh.e(var3)) {
            if (var2 > 0) {
               zaqb var10 = new zaqb();
               var10.a(var2);
               com.aspose.cells.b.a.a.ze.a(this.e, (Object)var10);
            }
         } else if (var3.indexOf("General") != -1) {
            this.a(var2);
         } else {
            String[] var6 = zaqh.l(var3);
            zaqb var7;
            if (var6.length <= 1) {
               var7 = new zaqb();
               var7.a("N" + var2, var2, var3);
               com.aspose.cells.b.a.a.ze.a(this.e, (Object)var7);
            } else {
               var7 = null;

               for(int var8 = 0; var8 < var6.length; ++var8) {
                  String var9 = var8 == var6.length - 1 ? "N" + var2 : "N" + var2 + "P" + var8;
                  var7 = new zaqb();
                  var7.a(var9, var2, var6[var8]);
                  if (var8 != var6.length - 1) {
                     com.aspose.cells.b.a.a.ze.a(var7.e, (Object)(new String[]{"style:volatile", "true"}));
                  }

                  com.aspose.cells.b.a.a.ze.a(this.e, (Object)var7);
               }

               var7.b(var6.length);
            }
         }
      }

   }

   void b(ArrayList var1) {
      for(int var2 = 0; var2 < var1.size(); ++var2) {
         Font var3 = (Font)var1.get(var2);
         boolean var4 = false;

         for(int var5 = 0; var5 < this.b.size(); ++var5) {
            zapw var6 = (zapw)this.b.get(var5);
            if (var6.a(var3)) {
               var4 = true;
               break;
            }
         }

         if (!var4) {
            com.aspose.cells.b.a.a.ze.a(this.b, (Object)(new zapw(var3)));
         }
      }

   }

   void a(zbvx var1) {
      HashMap var2 = new HashMap();

      int var3;
      for(var3 = this.e.size() - 1; var3 >= 0; --var3) {
         zaqb var4 = (zaqb)this.e.get(var3);
         if (var4.h) {
            int var5 = var4.c;
            --var3;

            for(; var3 >= 0; --var3) {
               zaqb var6 = (zaqb)this.e.get(var3);
               if (var6.c != var5) {
                  ++var3;
                  break;
               }

               switch(var6.d) {
               case 2:
               case 3:
                  switch(var4.d) {
                  case 5:
                  case 7:
                     var2.put(var4.c, 1);
                     continue;
                  default:
                     var2.put(var4.c, var6.d);
                     continue;
                  }
               default:
                  var2.put(var4.c, var6.d);
               }
            }
         } else {
            var2.put(var4.c, var4.d);
         }
      }

      this.h = new int[var1.getCount()];

      for(var3 = 0; var3 < var1.getCount(); ++var3) {
         Style var7 = var1.a(var3);
         com.aspose.cells.b.a.a.ze.a(this.f, (Object)(new zapq(var7, var3)));
         Object var8 = var2.get(var7.r());
         if (var8 == null) {
            this.h[var3] = 7;
         } else {
            this.h[var3] = (Integer)var8;
         }
      }

   }
}
